2017 © Pedro Peláez
 

library guardphp

(Perl) Guard for PHP

image

uzulla/guardphp

(Perl) Guard for PHP

  • Saturday, May 17, 2014
  • by uzulla
  • Repository
  • 2 Watchers
  • 3 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Guard for PHP

Like a Perl Scope::Guard, (*1)

SYNOPSIS

<?php
require "vendor/autoload.php";

use \Uzulla\Guard as Guard;

chdir('/usr'); # カレントディレクトリを/tmpに変更
echo getcwd().PHP_EOL; # カレントディレクトリを表示

call_user_func(function(){
    $g = new Guard(function(){ # Guardにコードを登録
        chdir('/usr');
    });
    chdir('/'); # カレントディレクトリを/に変更
    echo getcwd().PHP_EOL; # カレントディレクトリを表示
    # ここでscopeがおわるので、上で登録したコードが実行される
});

echo getcwd().PHP_EOL; # カレントディレクトリを表示

DESCRIPTION

Guardは特定のスコープを抜けたときに実行する関数を登録する事ができます。, (*2)

スコープを抜けたときに変数が開放されることを利用しているので、関数スコープのPHPでは無名関数などを使うとよいでしょう。, (*3)

変数名を変えれば、いくつでも作る事が可能ですが、実行順序は保証去れません。, (*4)

LICENSE

MIT, (*5)

The Versions

17/05 2014

dev-master

9999999-dev http://github.com/uzulla/guard_php

(Perl) Guard for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

util

17/05 2014

v1.0

1.0.0.0 http://github.com/uzulla/guard_php

(Perl) Guard for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

util