Skip to content

Commit a29c8be

Browse files
authored
Merge pull request #160 from homersimpsons/fix/unparenthesed-ternary
PHP74: Deprecated unparenthesed ternary
2 parents c6e4393 + 65d6d0d commit a29c8be

File tree

1 file changed

+83
-83
lines changed

1 file changed

+83
-83
lines changed

src/Mouf/Reflection/MoufReflectionProperty.php

+83-83
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
2-
/*
3-
* This file is part of the Mouf core package.
4-
*
5-
* (c) 2012 David Negrier <[email protected]>
6-
*
7-
* For the full copyright and license information, please view the LICENSE.txt
8-
* file that was distributed with this source code.
9-
*/
2+
/*
3+
* This file is part of the Mouf core package.
4+
*
5+
* (c) 2012 David Negrier <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE.txt
8+
* file that was distributed with this source code.
9+
*/
1010
namespace Mouf\Reflection;
11-
12-
use Mouf\MoufPropertyDescriptor;
11+
12+
use Mouf\MoufPropertyDescriptor;
1313

1414
/**
1515
* Extended Reflection class for class properties that allows usage of annotations.
@@ -154,57 +154,57 @@ public function equals($compare)
154154
* getDeclaringClass fixing the problem with traits
155155
* (non-PHPdoc)
156156
* @see ReflectionProperty::getDeclaringClass()
157-
*/
157+
*/
158158
function getDeclaringClass() {
159-
if ($this->declaringClass) {
160-
return $this->declaringClass;
161-
}
162-
163-
// Let's scan all traits
164-
$trait = $this->deepScanTraitsForProperty($this->refClass->getTraits());
159+
if ($this->declaringClass) {
160+
return $this->declaringClass;
161+
}
162+
163+
// Let's scan all traits
164+
$trait = $this->deepScanTraitsForProperty($this->refClass->getTraits());
165165
if ($trait != null) {
166-
$this->declaringClass = $trait;
167-
return $trait;
166+
$this->declaringClass = $trait;
167+
return $trait;
168168
}
169169

170170
if ($this->refClass->getParentClass()) {
171171
$declaringClass = null;
172172
if ($this->refClass->getParentClass()->hasProperty($this->getName())) {
173173
$declaringClass = $this->refClass->getParentClass()->getProperty($this->getName())->getDeclaringClass();
174174
}
175-
if ($declaringClass != null) {
176-
return $declaringClass;
177-
}
178-
}
179-
if ($this->refClass->hasProperty($this->getName())) {
180-
return $this->refClass;
175+
if ($declaringClass != null) {
176+
return $declaringClass;
177+
}
178+
}
179+
if ($this->refClass->hasProperty($this->getName())) {
180+
return $this->refClass;
181181
}
182182
return null;
183-
183+
184184
// The property is not part of the traits, let's find in which parent it is part of.
185185
/*$this->declaringClass = $this->getDeclaringClassWithoutTraits();
186-
return $this->declaringClass;*/
187-
}
188-
189-
/**
190-
* Recursive method called to detect a method into a nested array of traits.
191-
*
192-
* @param $traits ReflectionClass[]
193-
* @return ReflectionClass|null
194-
*/
195-
private function deepScanTraitsForProperty(array $traits) {
196-
foreach ($traits as $trait) {
197-
// If the trait has a property, it's a win!
198-
$result = $this->deepScanTraitsForProperty($trait->getTraits(), $this->getName());
199-
if ($result != null) {
200-
return $result;
201-
} else {
202-
if ($trait->hasProperty($this->getName())) {
203-
return $trait;
204-
}
205-
}
206-
}
207-
return null;
186+
return $this->declaringClass;*/
187+
}
188+
189+
/**
190+
* Recursive method called to detect a method into a nested array of traits.
191+
*
192+
* @param $traits ReflectionClass[]
193+
* @return ReflectionClass|null
194+
*/
195+
private function deepScanTraitsForProperty(array $traits) {
196+
foreach ($traits as $trait) {
197+
// If the trait has a property, it's a win!
198+
$result = $this->deepScanTraitsForProperty($trait->getTraits(), $this->getName());
199+
if ($result != null) {
200+
return $result;
201+
} else {
202+
if ($trait->hasProperty($this->getName())) {
203+
return $trait;
204+
}
205+
}
206+
}
207+
return null;
208208
}
209209

210210
/**
@@ -271,7 +271,7 @@ public function toXml(\SimpleXMLElement $root) {
271271
$node->appendChild($no->createCDATASection($this->getDocComment()));
272272

273273

274-
$propertyNode->addAttribute("modifier", $this->isPrivate() ? 'private' : $this->isProtected() ? "protected" : "public");
274+
$propertyNode->addAttribute("modifier", $this->isPrivate() ? 'private' : ($this->isProtected() ? "protected" : "public"));
275275
$propertyNode->addAttribute("is_static", $this->isStatic() ? "true" : "false");
276276

277277

@@ -286,46 +286,46 @@ public function toXml(\SimpleXMLElement $root) {
286286
}
287287
}
288288

289-
290-
/**
291-
* Returns a PHP array representing the property.
292-
*
293-
* @return array
294-
*/
295-
public function toJson() {
296-
$result = array();
297-
$result['name'] = $this->getName();
298-
$result['comment'] = $this->getMoufPhpDocComment()->getJsonArray();
299-
300-
/*$properties = $this->getAnnotations("Property");
301-
if (!empty($properties)) {
289+
290+
/**
291+
* Returns a PHP array representing the property.
292+
*
293+
* @return array
294+
*/
295+
public function toJson() {
296+
$result = array();
297+
$result['name'] = $this->getName();
298+
$result['comment'] = $this->getMoufPhpDocComment()->getJsonArray();
299+
300+
/*$properties = $this->getAnnotations("Property");
301+
if (!empty($properties)) {
302302
$result['moufProperty'] = true;*/
303303

304-
try {
304+
try {
305305
$result['default'] = $this->getDefault();
306306

307-
// TODO: is there a need to instanciate a MoufPropertyDescriptor?
308-
$moufPropertyDescriptor = new MoufPropertyDescriptor($this);
309-
$types = $moufPropertyDescriptor->getTypes();
310-
$result['types'] = $types->toJson();
311-
312-
if ($types->getWarningMessage()) {
313-
$result['classinerror'] = $types->getWarningMessage();
307+
// TODO: is there a need to instanciate a MoufPropertyDescriptor?
308+
$moufPropertyDescriptor = new MoufPropertyDescriptor($this);
309+
$types = $moufPropertyDescriptor->getTypes();
310+
$result['types'] = $types->toJson();
311+
312+
if ($types->getWarningMessage()) {
313+
$result['classinerror'] = $types->getWarningMessage();
314314
}
315315

316-
} catch (\Exception $e) {
317-
$result['classinerror'] = $e->getMessage();
318-
}
319-
/*if ($moufPropertyDescriptor->isAssociativeArray()) {
320-
$result['keytype'] = $moufPropertyDescriptor->getKeyType();
321-
}
322-
if ($moufPropertyDescriptor->isArray()) {
323-
$result['subtype'] = $moufPropertyDescriptor->getSubType();
324-
}*/
325-
//}
326-
327-
return $result;
328-
}
316+
} catch (\Exception $e) {
317+
$result['classinerror'] = $e->getMessage();
318+
}
319+
/*if ($moufPropertyDescriptor->isAssociativeArray()) {
320+
$result['keytype'] = $moufPropertyDescriptor->getKeyType();
321+
}
322+
if ($moufPropertyDescriptor->isArray()) {
323+
$result['subtype'] = $moufPropertyDescriptor->getSubType();
324+
}*/
325+
//}
326+
327+
return $result;
328+
}
329329

330330
}
331331
?>

0 commit comments

Comments
 (0)