Skip to content

Commit 41892d5

Browse files
jcheronaik099
authored andcommitted
slash before php global functions (php-annotations#121)
Added : \ before php global functions
1 parent 8a07ada commit 41892d5

10 files changed

+91
-91
lines changed

src/annotations/Annotation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ abstract class Annotation implements IAnnotation
2626
*/
2727
public function __get($name)
2828
{
29-
throw new AnnotationException(get_class($this) . "::\${$name} is not a valid property name");
29+
throw new AnnotationException(\get_class($this) . "::\${$name} is not a valid property name");
3030
}
3131

3232
/**
3333
* Insulation against write-access to undeclared properties
3434
*/
3535
public function __set($name, $value)
3636
{
37-
throw new AnnotationException(get_class($this) . "::\${$name} is not a valid property name");
37+
throw new AnnotationException(\get_class($this) . "::\${$name} is not a valid property name");
3838
}
3939

4040
/**

src/annotations/AnnotationCache.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __construct($root, $fileMode = 0777)
5454
*/
5555
public function exists($key)
5656
{
57-
return file_exists($this->_getPath($key));
57+
return \file_exists($this->_getPath($key));
5858
}
5959

6060
/**
@@ -70,11 +70,11 @@ public function store($key, $code)
7070

7171
$content = self::PHP_TAG . $code . "\n";
7272

73-
if (@file_put_contents($path, $content, LOCK_EX) === false) {
73+
if (@\file_put_contents($path, $content, LOCK_EX) === false) {
7474
throw new AnnotationException("Unable to write cache file: {$path}");
7575
}
7676

77-
if (@chmod($path, $this->_fileMode) === false) {
77+
if (@\chmod($path, $this->_fileMode) === false) {
7878
throw new AnnotationException("Unable to set permissions of cache file: {$path}");
7979
}
8080
}
@@ -98,7 +98,7 @@ public function fetch($key)
9898
*/
9999
public function getTimestamp($key)
100100
{
101-
return filemtime($this->_getPath($key));
101+
return \filemtime($this->_getPath($key));
102102
}
103103

104104
/**

src/annotations/AnnotationFile.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function __construct($path, array $data)
7777

7878
if (isset($data['#traitMethodOverrides'])) {
7979
foreach ($data['#traitMethodOverrides'] as $class => $methods) {
80-
$this->traitMethodOverrides[$class] = array_map(array($this, 'resolveMethod'), $methods);
80+
$this->traitMethodOverrides[$class] = \array_map(array($this, 'resolveMethod'), $methods);
8181
}
8282
}
8383
}
@@ -91,8 +91,8 @@ public function __construct($path, array $data)
9191
*/
9292
public function resolveMethod($raw_method)
9393
{
94-
list($class, $method) = explode('::', $raw_method, 2);
95-
return array(ltrim($this->resolveType($class), '\\'), $method);
94+
list($class, $method) = \explode('::', $raw_method, 2);
95+
return array(\ltrim($this->resolveType($class), '\\'), $method);
9696
}
9797

9898
/**
@@ -105,18 +105,18 @@ public function resolveMethod($raw_method)
105105
*/
106106
public function resolveType($raw_type)
107107
{
108-
$type_parts = explode('[]', $raw_type, 2);
108+
$type_parts = \explode('[]', $raw_type, 2);
109109
$type = $type_parts[0];
110110

111111
if (!$this->isSimple($type)) {
112112
if (isset($this->uses[$type])) {
113113
$type_parts[0] = $this->uses[$type];
114-
} elseif ($this->namespace && substr($type, 0, 1) != '\\') {
114+
} elseif ($this->namespace && \substr($type, 0, 1) != '\\') {
115115
$type_parts[0] = $this->namespace . '\\' . $type;
116116
}
117117
}
118118

119-
return implode('[]', $type_parts);
119+
return \implode('[]', $type_parts);
120120
}
121121

122122
/**
@@ -128,6 +128,6 @@ public function resolveType($raw_type)
128128
*/
129129
protected function isSimple($type)
130130
{
131-
return in_array(strtolower($type), self::$simpleTypes);
131+
return \in_array(\strtolower($type), self::$simpleTypes);
132132
}
133133
}

src/annotations/AnnotationManager.php

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function __construct($cacheSeed = '')
152152
$this->_usageAnnotation = new UsageAnnotation();
153153
$this->_usageAnnotation->class = true;
154154
$this->_usageAnnotation->inherited = true;
155-
$this->_traitsSupported = version_compare(PHP_VERSION, '5.4.0', '>=');
155+
$this->_traitsSupported = \version_compare(PHP_VERSION, '5.4.0', '>=');
156156
}
157157

158158
/**
@@ -195,10 +195,10 @@ protected function getAnnotationFile($path)
195195
$code = $this->getParser()->parseFile($path);
196196
$data = eval($code);
197197
} else {
198-
$checksum = crc32($path . ':' . $this->_cacheSeed . ':' . self::CACHE_FORMAT_VERSION);
199-
$key = basename($path) . '-' . sprintf('%x', $checksum);
198+
$checksum = \crc32($path . ':' . $this->_cacheSeed . ':' . self::CACHE_FORMAT_VERSION);
199+
$key = \basename($path) . '-' . \sprintf('%x', $checksum);
200200

201-
if (($this->cache->exists($key) === false) || (filemtime($path) > $this->cache->getTimestamp($key))) {
201+
if (($this->cache->exists($key) === false) || (\filemtime($path) > $this->cache->getTimestamp($key))) {
202202
$code = $this->getParser()->parseFile($path);
203203
$this->cache->store($key, $code);
204204
}
@@ -224,19 +224,19 @@ protected function getAnnotationFile($path)
224224
*/
225225
public function resolveName($name)
226226
{
227-
if (strpos($name, '\\') !== false) {
227+
if (\strpos($name, '\\') !== false) {
228228
return $name . $this->suffix; // annotation class-name is fully qualified
229229
}
230230

231-
$type = lcfirst($name);
231+
$type = \lcfirst($name);
232232

233233
if (isset($this->registry[$type])) {
234234
return $this->registry[$type]; // type-name is registered
235235
}
236236

237-
$type = ucfirst(strtr($name, '-', '_')) . $this->suffix;
237+
$type = \ucfirst(\strtr($name, '-', '_')) . $this->suffix;
238238

239-
return strlen($this->namespace)
239+
return \strlen($this->namespace)
240240
? $this->namespace . '\\' . $type
241241
: $type;
242242
}
@@ -279,7 +279,7 @@ protected function getAnnotations($class_name, $member_type = self::MEMBER_CLASS
279279

280280
unset($spec['#name'], $spec['#type']);
281281

282-
if (!class_exists($type, $this->autoload)) {
282+
if (!\class_exists($type, $this->autoload)) {
283283
throw new AnnotationException("Annotation type '{$type}' does not exist");
284284
}
285285

@@ -316,7 +316,7 @@ protected function getAnnotations($class_name, $member_type = self::MEMBER_CLASS
316316
}
317317
}
318318

319-
$annotations = array_merge($traitAnnotations, $annotations);
319+
$annotations = \array_merge($traitAnnotations, $annotations);
320320
}
321321
}
322322

@@ -331,13 +331,13 @@ protected function getAnnotations($class_name, $member_type = self::MEMBER_CLASS
331331

332332
if ($parent !== __NAMESPACE__ . '\Annotation') {
333333
foreach ($this->getAnnotations($parent, $member_type, $member_name) as $annotation) {
334-
if ($this->getUsage(get_class($annotation))->inherited) {
334+
if ($this->getUsage(\get_class($annotation))->inherited) {
335335
$parent_annotations[] = $annotation;
336336
}
337337
}
338338
}
339339

340-
$annotations = array_merge($parent_annotations, $annotations);
340+
$annotations = \array_merge($parent_annotations, $annotations);
341341
}
342342

343343
$this->annotations[$key] = $this->applyConstraints($annotations, $member_type);
@@ -360,9 +360,9 @@ protected function getAnnotations($class_name, $member_type = self::MEMBER_CLASS
360360
protected function classHasMember($className, $memberType, $memberName)
361361
{
362362
if ($memberType === self::MEMBER_METHOD) {
363-
return method_exists($className, $memberName);
363+
return \method_exists($className, $memberName);
364364
} else if ($memberType === self::MEMBER_PROPERTY) {
365-
return property_exists($className, ltrim($memberName, '$'));
365+
return \property_exists($className, \ltrim($memberName, '$'));
366366
}
367367
return false;
368368
}
@@ -381,10 +381,10 @@ protected function classHasMember($className, $memberType, $memberName)
381381
protected function applyConstraints(array $annotations, $member)
382382
{
383383
$result = array();
384-
$annotationCount = count($annotations);
384+
$annotationCount = \count($annotations);
385385

386386
foreach ($annotations as $outerIndex => $annotation) {
387-
$type = get_class($annotation);
387+
$type = \get_class($annotation);
388388
$usage = $this->getUsage($type);
389389

390390
// Checks, that annotation can be applied to given class/method/property according to it's @usage annotation.
@@ -424,8 +424,8 @@ protected function applyConstraints(array $annotations, $member)
424424
*/
425425
protected function filterAnnotations(array $annotations, $type)
426426
{
427-
if (substr($type, 0, 1) === '@') {
428-
$type = $this->resolveName(substr($type, 1));
427+
if (\substr($type, 0, 1) === '@') {
428+
$type = $this->resolveName(\substr($type, 1));
429429
}
430430

431431
if ($type === false) {
@@ -457,16 +457,16 @@ public function getUsage($class)
457457
}
458458

459459
if (!isset($this->usage[$class])) {
460-
if (!class_exists($class, $this->autoload)) {
460+
if (!\class_exists($class, $this->autoload)) {
461461
throw new AnnotationException("Annotation type '{$class}' does not exist");
462462
}
463463

464464
$usage = $this->getAnnotations($class);
465465

466-
if (count($usage) === 0) {
466+
if (\count($usage) === 0) {
467467
throw new AnnotationException("The class '{$class}' must have exactly one UsageAnnotation");
468468
} else {
469-
if (count($usage) !== 1 || !($usage[0] instanceof UsageAnnotation)) {
469+
if (\count($usage) !== 1 || !($usage[0] instanceof UsageAnnotation)) {
470470
throw new AnnotationException("The class '{$class}' must have exactly one UsageAnnotation (no other Annotations are allowed)");
471471
} else {
472472
$usage = $usage[0];
@@ -493,16 +493,16 @@ public function getClassAnnotations($class, $type = null)
493493
{
494494
if ($class instanceof \ReflectionClass) {
495495
$class = $class->getName();
496-
} elseif (is_object($class)) {
497-
$class = get_class($class);
496+
} elseif (\is_object($class)) {
497+
$class = \get_class($class);
498498
} else {
499-
$class = ltrim($class, '\\');
499+
$class = \ltrim($class, '\\');
500500
}
501501

502-
if (!class_exists($class, $this->autoload) &&
503-
!(function_exists('trait_exists') && trait_exists($class, $this->autoload))
502+
if (!\class_exists($class, $this->autoload) &&
503+
!(\function_exists('trait_exists') && \trait_exists($class, $this->autoload))
504504
) {
505-
if (interface_exists($class, $this->autoload)) {
505+
if (\interface_exists($class, $this->autoload)) {
506506
throw new AnnotationException("Reading annotations from interface '{$class}' is not supported");
507507
}
508508

@@ -534,17 +534,17 @@ public function getMethodAnnotations($class, $method = null, $type = null)
534534
} elseif ($class instanceof \ReflectionMethod) {
535535
$method = $class->name;
536536
$class = $class->class;
537-
} elseif (is_object($class)) {
538-
$class = get_class($class);
537+
} elseif (\is_object($class)) {
538+
$class = \get_class($class);
539539
} else {
540-
$class = ltrim($class, '\\');
540+
$class = \ltrim($class, '\\');
541541
}
542542

543-
if (!class_exists($class, $this->autoload)) {
543+
if (!\class_exists($class, $this->autoload)) {
544544
throw new AnnotationException("Unable to read annotations from an undefined class '{$class}'");
545545
}
546546

547-
if (!method_exists($class, $method)) {
547+
if (!\method_exists($class, $method)) {
548548
throw new AnnotationException("Unable to read annotations from an undefined method {$class}::{$method}()");
549549
}
550550

@@ -574,17 +574,17 @@ public function getPropertyAnnotations($class, $property = null, $type = null)
574574
} elseif ($class instanceof \ReflectionProperty) {
575575
$property = $class->name;
576576
$class = $class->class;
577-
} elseif (is_object($class)) {
578-
$class = get_class($class);
577+
} elseif (\is_object($class)) {
578+
$class = \get_class($class);
579579
} else {
580-
$class = ltrim($class, '\\');
580+
$class = \ltrim($class, '\\');
581581
}
582582

583-
if (!class_exists($class, $this->autoload)) {
583+
if (!\class_exists($class, $this->autoload)) {
584584
throw new AnnotationException("Unable to read annotations from an undefined class '{$class}'");
585585
}
586586

587-
if (!property_exists($class, $property)) {
587+
if (!\property_exists($class, $property)) {
588588
throw new AnnotationException("Unable to read annotations from an undefined property {$class}::\${$property}");
589589
}
590590

0 commit comments

Comments
 (0)