Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
f0b01009
Commit
f0b01009
authored
Nov 28, 2007
by
Jonathan.Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code formatting.
parent
fc34ba6e
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
368 additions
and
373 deletions
+368
-373
FileFinder.php
lib/Doctrine/FileFinder.php
+135
-373
GlobToRegex.php
lib/Doctrine/FileFinder/GlobToRegex.php
+127
-0
NumberCompare.php
lib/Doctrine/FileFinder/NumberCompare.php
+106
-0
No files found.
lib/Doctrine/FileFinder.php
View file @
f0b01009
This diff is collapsed.
Click to expand it.
lib/Doctrine/FileFinder/GlobToRegex.php
0 → 100644
View file @
f0b01009
<?php
/*
* $Id$
*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_FileFinder_GlobToRegex
*
* Match globbing patterns against text.
*
* if match_glob("foo.*", "foo.bar") echo "matched\n";
*
* // prints foo.bar and foo.baz
* $regex = globToRegex("foo.*");
* for (array('foo.bar', 'foo.baz', 'foo', 'bar') as $t)
* {
* if (/$regex/) echo "matched: $car\n";
* }
*
* Doctrine_FileFinder_GlobToRegex implements glob(3) style matching that can be used to match
* against text, rather than fetching names from a filesystem.
*
* based on perl Text::Glob module.
*
* @package Doctrine
* @subpackage FileFinder
* @author Fabien Potencier <fabien.potencier@gmail.com> php port
* @author Richard Clamp <richardc@unixbeard.net> perl version
* @copyright 2004-2005 Fabien Potencier <fabien.potencier@gmail.com>
* @copyright 2002 Richard Clamp <richardc@unixbeard.net>
* @version SVN: $Id: Doctrine_FileFinder.class.php 5110 2007-09-15 12:07:18Z fabien $
*/
class
Doctrine_FileFinder_GlobToRegex
{
protected
static
$strictLeadingDot
=
true
;
protected
static
$strictWildcardSlash
=
true
;
public
static
function
setStrictLeadingDot
(
$boolean
)
{
self
::
$strictLeadingDot
=
$boolean
;
}
public
static
function
setStrictWildcardSlash
(
$boolean
)
{
self
::
$strictWildcardSlash
=
$boolean
;
}
/**
* Returns a compiled regex which is the equiavlent of the globbing pattern.
*
* @param string glob pattern
* @return string regex
*/
public
static
function
globToRegex
(
$glob
)
{
$firstByte
=
true
;
$escaping
=
false
;
$inCurlies
=
0
;
$regex
=
''
;
for
(
$i
=
0
;
$i
<
strlen
(
$glob
);
$i
++
)
{
$car
=
$glob
[
$i
];
if
(
$firstByte
)
{
if
(
self
::
$strictLeadingDot
&&
$car
!=
'.'
)
{
$regex
.=
'(?=[^\.])'
;
}
$firstByte
=
false
;
}
if
(
$car
==
'/'
)
{
$firstByte
=
true
;
}
if
(
$car
==
'.'
||
$car
==
'('
||
$car
==
')'
||
$car
==
'|'
||
$car
==
'+'
||
$car
==
'^'
||
$car
==
'$'
)
{
$regex
.=
"
\\
$car
"
;
}
else
if
(
$car
==
'*'
)
{
$regex
.=
(
$escaping
?
"
\\
*"
:
(
self
::
$strictWildcardSlash
?
"[^/]*"
:
".*"
));
}
else
if
(
$car
==
'?'
)
{
$regex
.=
(
$escaping
?
"
\\
?"
:
(
self
::
$strictWildcardSlash
?
"[^/]"
:
"."
));
}
else
if
(
$car
==
'{'
)
{
$regex
.=
(
$escaping
?
"
\\
{"
:
"("
);
if
(
!
$escaping
)
{
++
$inCurlies
;
}
}
else
if
(
$car
==
'}'
&&
$inCurlies
)
{
$regex
.=
(
$escaping
?
"}"
:
")"
);
if
(
!
$escaping
)
{
--
$inCurlies
;
}
}
else
if
(
$car
==
','
&&
$inCurlies
)
{
$regex
.=
(
$escaping
?
","
:
"|"
);
}
else
if
(
$car
==
"
\\
"
)
{
if
(
$escaping
)
{
$regex
.=
"
\\\\
"
;
$escaping
=
false
;
}
else
{
$escaping
=
true
;
}
continue
;
}
else
{
$regex
.=
$car
;
$escaping
=
false
;
}
$escaping
=
false
;
}
return
"#^
$regex
$#"
;
}
}
\ No newline at end of file
lib/Doctrine/FileFinder/NumberCompare.php
0 → 100644
View file @
f0b01009
<?php
/*
* $Id$
*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_FileFinder_NumberCompare
*
* Numeric comparisons.
*
* Doctrine_FileFinder_NumberCompare compiles a simple comparison to an anonymous
* subroutine, which you can call with a value to be tested again.
*
* Now this would be very pointless, if Doctrine_FileFinder_NumberCompare didn't understand
* magnitudes.
*
* The target value may use magnitudes of kilobytes (k, ki),
* megabytes (m, mi), or gigabytes (g, gi). Those suffixed
* with an i use the appropriate 2**n version in accordance with the
* IEC standard: http://physics.nist.gov/cuu/Units/binary.html
*
* based on perl Number::Compare module.
*
* @package Doctrine
* @subpackage FileFinder
* @author Fabien Potencier <fabien.potencier@gmail.com> php port
* @author Richard Clamp <richardc@unixbeard.net> perl version
* @copyright 2004-2005 Fabien Potencier <fabien.potencier@gmail.com>
* @copyright 2002 Richard Clamp <richardc@unixbeard.net>
* @see http://physics.nist.gov/cuu/Units/binary.html
* @version SVN: $Id: Doctrine_FileFinder.class.php 5110 2007-09-15 12:07:18Z fabien $
*/
class
Doctrine_FileFinder_NumberCompare
{
protected
$test
=
''
;
public
function
__construct
(
$test
)
{
$this
->
test
=
$test
;
}
public
function
test
(
$number
)
{
if
(
!
preg_match
(
'{^([<>]=?)?(.*?)([kmg]i?)?$}i'
,
$this
->
test
,
$matches
))
{
throw
new
Doctrine_Exception
(
sprintf
(
'don\'t understand "%s" as a test.'
,
$this
->
test
));
}
$target
=
array_key_exists
(
2
,
$matches
)
?
$matches
[
2
]
:
''
;
$magnitude
=
array_key_exists
(
3
,
$matches
)
?
$matches
[
3
]
:
''
;
if
(
strtolower
(
$magnitude
)
==
'k'
)
{
$target
*=
1000
;
}
if
(
strtolower
(
$magnitude
)
==
'ki'
)
{
$target
*=
1024
;
}
if
(
strtolower
(
$magnitude
)
==
'm'
)
{
$target
*=
1000000
;
}
if
(
strtolower
(
$magnitude
)
==
'mi'
)
{
$target
*=
1024
*
1024
;
}
if
(
strtolower
(
$magnitude
)
==
'g'
)
{
$target
*=
1000000000
;
}
if
(
strtolower
(
$magnitude
)
==
'gi'
)
{
$target
*=
1024
*
1024
*
1024
;
}
$comparison
=
array_key_exists
(
1
,
$matches
)
?
$matches
[
1
]
:
'=='
;
if
(
$comparison
==
'=='
||
$comparison
==
''
)
{
return
(
$number
==
$target
);
}
else
if
(
$comparison
==
'>'
)
{
return
(
$number
>
$target
);
}
else
if
(
$comparison
==
'>='
)
{
return
(
$number
>=
$target
);
}
else
if
(
$comparison
==
'<'
)
{
return
(
$number
<
$target
);
}
else
if
(
$comparison
==
'<='
)
{
return
(
$number
<=
$target
);
}
return
false
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment