Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Doc: IsClassProperty moved to new, class-oriented format
- Loading branch information
1 parent
8f579e2
commit 3de28d2
Showing
34 changed files
with
814 additions
and
2 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
doc-examples/IsClassProperty/__construct/Example-1--Check-For-Class-Property.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
require_once 'vendor/autoload.php'; | ||
require_once __DIR__ . '/ExampleClass.inc.php'; | ||
|
||
// --- TARGET START --- | ||
// defaults | ||
// --- TARGET STOP --- | ||
// --- PREAMBLE START --- | ||
// This example shows you how to check if a property is a class property. | ||
// --- PREAMBLE STOP --- | ||
|
||
// --- EXAMPLE START --- | ||
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty; | ||
|
||
$checker = new IsClassProperty; | ||
|
||
// here, $refProp reflects a static property | ||
$refClass = new ReflectionClass(ExampleClass::class); | ||
$refProp = $refClass->getProperty('value1'); | ||
var_dump($checker->inspect($refProp)); | ||
|
||
// here, $refProp reflects an object's property | ||
$target = new ExampleClass; | ||
$refObj = new ReflectionObject($target); | ||
$refProp = $refObj->getProperty('value2'); | ||
var_dump($checker->inspect($refProp)); |
7 changes: 7 additions & 0 deletions
7
doc-examples/IsClassProperty/__construct/ExampleClass.inc.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
class ExampleClass | ||
{ | ||
public static $value1 = "I am public static value1"; | ||
public $value2 = "I am public value2"; | ||
} |
25 changes: 25 additions & 0 deletions
25
doc-examples/IsClassProperty/check/Example-1--Check-For-Class-Property.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
require_once 'vendor/autoload.php'; | ||
require_once __DIR__ . '/ExampleClass.inc.php'; | ||
|
||
// --- TARGET START --- | ||
// defaults | ||
// --- TARGET STOP --- | ||
// --- PREAMBLE START --- | ||
// This example shows you how to check if a property is a class property | ||
// --- PREAMBLE STOP --- | ||
|
||
// --- EXAMPLE START --- | ||
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty; | ||
|
||
// here, $refProp reflects a static property | ||
$refClass = new ReflectionClass(ExampleClass::class); | ||
$refProp = $refClass->getProperty('value1'); | ||
var_dump(IsClassProperty::check($refProp)); | ||
|
||
// here, $refProp reflects an object's property | ||
$target = new ExampleClass; | ||
$refObj = new ReflectionObject($target); | ||
$refProp = $refObj->getProperty('value2'); | ||
var_dump(IsClassProperty::check($refProp)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
class ExampleClass | ||
{ | ||
public static $value1 = "I am public static value1"; | ||
public $value2 = "I am public value2"; | ||
} |
34 changes: 34 additions & 0 deletions
34
doc-examples/IsClassProperty/checkList/Example-1--Check-List-For-Class-Properties.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
require_once 'vendor/autoload.php'; | ||
require_once __DIR__ . '/ExampleClass.inc.php'; | ||
|
||
// --- TARGET START --- | ||
// defaults | ||
// --- TARGET STOP --- | ||
// --- PREAMBLE START --- | ||
// This example shows you how to check if a list contains only class properties. | ||
// --- PREAMBLE STOP --- | ||
|
||
// --- EXAMPLE START --- | ||
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty; | ||
|
||
$refClass = new ReflectionClass(ExampleClass::class); | ||
$refProp1 = $refClass->getProperty('value1'); | ||
|
||
// here, $refProp reflects an object's property | ||
$target = new ExampleClass; | ||
$refObj = new ReflectionObject($target); | ||
$refProp2 = $refObj->getProperty('value2'); | ||
|
||
// this list only contains class properties | ||
var_dump(IsClassProperty::checkList([ | ||
$refProp1 | ||
])); | ||
|
||
// this list contains both class properties | ||
// and object properties | ||
var_dump(IsClassProperty::checkList([ | ||
$refProp1, | ||
$refProp2 | ||
])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
class ExampleClass | ||
{ | ||
public static $value1 = "I am public static value1"; | ||
public $value2 = "I am public value2"; | ||
} |
27 changes: 27 additions & 0 deletions
27
doc-examples/IsClassProperty/inspect/Example-1--Check-For-Class-Property.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
require_once 'vendor/autoload.php'; | ||
require_once __DIR__ . '/ExampleClass.inc.php'; | ||
|
||
// --- TARGET START --- | ||
// defaults | ||
// --- TARGET STOP --- | ||
// --- PREAMBLE START --- | ||
// This example shows you how to check if a property is a class property. | ||
// --- PREAMBLE STOP --- | ||
|
||
// --- EXAMPLE START --- | ||
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty; | ||
|
||
$checker = new IsClassProperty; | ||
|
||
// here, $refProp reflects a static property | ||
$refClass = new ReflectionClass(ExampleClass::class); | ||
$refProp = $refClass->getProperty('value1'); | ||
var_dump($checker->inspect($refProp)); | ||
|
||
// here, $refProp reflects an object's property | ||
$target = new ExampleClass; | ||
$refObj = new ReflectionObject($target); | ||
$refProp = $refObj->getProperty('value2'); | ||
var_dump($checker->inspect($refProp)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
class ExampleClass | ||
{ | ||
public static $value1 = "I am public static value1"; | ||
public $value2 = "I am public value2"; | ||
} |
36 changes: 36 additions & 0 deletions
36
doc-examples/IsClassProperty/inspectList/Example-1--Check-List-For-Class-Properties.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
require_once 'vendor/autoload.php'; | ||
require_once __DIR__ . '/ExampleClass.inc.php'; | ||
|
||
// --- TARGET START --- | ||
// defaults | ||
// --- TARGET STOP --- | ||
// --- PREAMBLE START --- | ||
// This example shows you how to check if a list contains only class properties. | ||
// --- PREAMBLE STOP --- | ||
|
||
// --- EXAMPLE START --- | ||
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty; | ||
|
||
$checker = new IsClassProperty; | ||
|
||
$refClass = new ReflectionClass(ExampleClass::class); | ||
$refProp1 = $refClass->getProperty('value1'); | ||
|
||
// here, $refProp reflects an object's property | ||
$target = new ExampleClass; | ||
$refObj = new ReflectionObject($target); | ||
$refProp2 = $refObj->getProperty('value2'); | ||
|
||
// this list only contains class properties | ||
var_dump($checker->inspectList([ | ||
$refProp1 | ||
])); | ||
|
||
// this list contains both class properties | ||
// and object properties | ||
var_dump($checker->inspectList([ | ||
$refProp1, | ||
$refProp2 | ||
])); |
7 changes: 7 additions & 0 deletions
7
doc-examples/IsClassProperty/inspectList/ExampleClass.inc.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
class ExampleClass | ||
{ | ||
public static $value1 = "I am public static value1"; | ||
public $value2 = "I am public value2"; | ||
} |
25 changes: 25 additions & 0 deletions
25
doc-examples/IsClassProperty/using/Example-1--Shorthand-Notation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
require_once 'vendor/autoload.php'; | ||
require_once __DIR__ . '/ExampleClass.inc.php'; | ||
|
||
// --- TARGET START --- | ||
// defaults | ||
// --- TARGET STOP --- | ||
// --- PREAMBLE START --- | ||
// This example shows you how to use the shorthand notation, to avoid creating a variable for the checker. | ||
// --- PREAMBLE STOP --- | ||
|
||
// --- EXAMPLE START --- | ||
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty; | ||
|
||
// here, $refProp reflects a static property | ||
$refClass = new ReflectionClass(ExampleClass::class); | ||
$refProp = $refClass->getProperty('value1'); | ||
var_dump(IsClassProperty::using()->inspect($refProp)); | ||
|
||
// here, $refProp reflects an object's property | ||
$target = new ExampleClass; | ||
$refObj = new ReflectionObject($target); | ||
$refProp = $refObj->getProperty('value2'); | ||
var_dump(IsClassProperty::using()->inspect($refProp)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
class ExampleClass | ||
{ | ||
public static $value1 = "I am public static value1"; | ||
public $value2 = "I am public value2"; | ||
} |
2 changes: 1 addition & 1 deletion
2
....i/code-metrics/GanbaroDigital/MissingBits/ClassesAndObjects/IsClassProperty.inspect.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<div class="code-metrics"> | ||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="90" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h59v20H0z"/><path fill="#4c1" d="M59 0h31v20H59z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="29.5" y="14">coverage</text><text x="73.5" y="14">100</text></g></svg> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="86" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h69v20H0z"/><path fill="#4c1" d="M69 0h17v20H69z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="34.5" y="14">complexity</text><text x="76.5" y="14">1</text></g></svg> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="56" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h39v20H0z"/><path fill="#4c1" d="M39 0h17v20H39z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="19.5" y="14">CRAP</text><text x="46.5" y="14">1</text></g></svg> | ||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h59v20H0z"/><path fill="#dfb317" d="M59 0h41v20H59z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="29.5" y="14">coverage</text><text x="78.5" y="14">66.67</text></g></svg> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="86" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h69v20H0z"/><path fill="#4c1" d="M69 0h17v20H69z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="34.5" y="14">complexity</text><text x="76.5" y="14">2</text></g></svg> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="56" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h39v20H0z"/><path fill="#4c1" d="M39 0h17v20H39z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="19.5" y="14">CRAP</text><text x="46.5" y="14">2</text></g></svg> | ||
</div> |
3 changes: 3 additions & 0 deletions
3
docs/.i/code-metrics/GanbaroDigital/MissingBits/ClassesAndObjects/IsClassProperty.using.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="code-metrics"> | ||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="76" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h59v20H0z"/><path fill="#e05d44" d="M59 0h17v20H59z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="29.5" y="14">coverage</text><text x="66.5" y="14">0</text></g></svg> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="86" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h69v20H0z"/><path fill="#4c1" d="M69 0h17v20H69z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="34.5" y="14">complexity</text><text x="76.5" y="14">1</text></g></svg> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="56" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h39v20H0z"/><path fill="#4c1" d="M39 0h17v20H39z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="19.5" y="14">CRAP</text><text x="46.5" y="14">2</text></g></svg> | ||
</div> |
26 changes: 26 additions & 0 deletions
26
docs/.i/examples/IsClassProperty/__construct/Example-1--Check-For-Class-Property.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
### Example 1: Check For Class Property | ||
|
||
This example shows you how to check if a property is a class property. | ||
|
||
```php | ||
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty; | ||
|
||
$checker = new IsClassProperty; | ||
|
||
// here, $refProp reflects a static property | ||
$refClass = new ReflectionClass(ExampleClass::class); | ||
$refProp = $refClass->getProperty('value1'); | ||
var_dump($checker->inspect($refProp)); | ||
|
||
// here, $refProp reflects an object's property | ||
$target = new ExampleClass; | ||
$refObj = new ReflectionObject($target); | ||
$refProp = $refObj->getProperty('value2'); | ||
var_dump($checker->inspect($refProp)); | ||
``` | ||
The code above produces this output on PHP v5.6.30, PHP v7.0.20, PHP v7.1.6: | ||
|
||
``` | ||
bool(true) | ||
bool(false) | ||
``` |
7 changes: 7 additions & 0 deletions
7
docs/.i/examples/IsClassProperty/__construct/ExampleClass.inc.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<pre><code class="language-php"> | ||
class ExampleClass | ||
{ | ||
public static $value1 = "I am public static value1"; | ||
public $value2 = "I am public value2"; | ||
} | ||
</code></pre> |
24 changes: 24 additions & 0 deletions
24
docs/.i/examples/IsClassProperty/check/Example-1--Check-For-Class-Property.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
### Example 1: Check For Class Property | ||
|
||
This example shows you how to check if a property is a class property | ||
|
||
```php | ||
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty; | ||
|
||
// here, $refProp reflects a static property | ||
$refClass = new ReflectionClass(ExampleClass::class); | ||
$refProp = $refClass->getProperty('value1'); | ||
var_dump(IsClassProperty::check($refProp)); | ||
|
||
// here, $refProp reflects an object's property | ||
$target = new ExampleClass; | ||
$refObj = new ReflectionObject($target); | ||
$refProp = $refObj->getProperty('value2'); | ||
var_dump(IsClassProperty::check($refProp)); | ||
``` | ||
The code above produces this output on PHP v5.6.30, PHP v7.0.20, PHP v7.1.6: | ||
|
||
``` | ||
bool(true) | ||
bool(false) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<pre><code class="language-php"> | ||
class ExampleClass | ||
{ | ||
public static $value1 = "I am public static value1"; | ||
public $value2 = "I am public value2"; | ||
} | ||
</code></pre> |
33 changes: 33 additions & 0 deletions
33
docs/.i/examples/IsClassProperty/checkList/Example-1--Check-List-For-Class-Properties.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
### Example 1: Check List For Class Properties | ||
|
||
This example shows you how to check if a list contains only class properties. | ||
|
||
```php | ||
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty; | ||
|
||
$refClass = new ReflectionClass(ExampleClass::class); | ||
$refProp1 = $refClass->getProperty('value1'); | ||
|
||
// here, $refProp reflects an object's property | ||
$target = new ExampleClass; | ||
$refObj = new ReflectionObject($target); | ||
$refProp2 = $refObj->getProperty('value2'); | ||
|
||
// this list only contains class properties | ||
var_dump(IsClassProperty::checkList([ | ||
$refProp1 | ||
])); | ||
|
||
// this list contains both class properties | ||
// and object properties | ||
var_dump(IsClassProperty::checkList([ | ||
$refProp1, | ||
$refProp2 | ||
])); | ||
``` | ||
The code above produces this output on PHP v5.6.30, PHP v7.0.20, PHP v7.1.6: | ||
|
||
``` | ||
bool(true) | ||
bool(false) | ||
``` |
7 changes: 7 additions & 0 deletions
7
docs/.i/examples/IsClassProperty/checkList/ExampleClass.inc.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<pre><code class="language-php"> | ||
class ExampleClass | ||
{ | ||
public static $value1 = "I am public static value1"; | ||
public $value2 = "I am public value2"; | ||
} | ||
</code></pre> |
26 changes: 26 additions & 0 deletions
26
docs/.i/examples/IsClassProperty/inspect/Example-1--Check-For-Class-Property.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
### Example 1: Check For Class Property | ||
|
||
This example shows you how to check if a property is a class property. | ||
|
||
```php | ||
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty; | ||
|
||
$checker = new IsClassProperty; | ||
|
||
// here, $refProp reflects a static property | ||
$refClass = new ReflectionClass(ExampleClass::class); | ||
$refProp = $refClass->getProperty('value1'); | ||
var_dump($checker->inspect($refProp)); | ||
|
||
// here, $refProp reflects an object's property | ||
$target = new ExampleClass; | ||
$refObj = new ReflectionObject($target); | ||
$refProp = $refObj->getProperty('value2'); | ||
var_dump($checker->inspect($refProp)); | ||
``` | ||
The code above produces this output on PHP v5.6.30, PHP v7.0.20, PHP v7.1.6: | ||
|
||
``` | ||
bool(true) | ||
bool(false) | ||
``` |
7 changes: 7 additions & 0 deletions
7
docs/.i/examples/IsClassProperty/inspect/ExampleClass.inc.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<pre><code class="language-php"> | ||
class ExampleClass | ||
{ | ||
public static $value1 = "I am public static value1"; | ||
public $value2 = "I am public value2"; | ||
} | ||
</code></pre> |
Oops, something went wrong.