Skip to content

Commit 9ffa719

Browse files
committed
Migrated PEAR naming to PSR-4.
Added PHP CS Fixer to clean up code. Updated Travis configuration to work with new configuration. Update Composer configuration to work with new configuration. Overall tweaks in code to work with new naming conventions and fix minor bugs.
1 parent f39b93f commit 9ffa719

File tree

93 files changed

+4721
-4081
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+4721
-4081
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ utils/dist/
44
utils/tmp/
55
utils/starting_HEAD
66
/.settings
7+
.idea/
8+
vendor/
9+
.php_cs.cache
10+
composer.lock

.php_cs

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
use Symfony\CS\Config\Config;
4+
use Symfony\CS\FixerInterface;
5+
use Symfony\CS\Finder\DefaultFinder;
6+
7+
$fixers = [
8+
'blankline_after_open_tag',
9+
'braces',
10+
'concat_without_spaces',
11+
'double_arrow_multiline_whitespaces',
12+
'duplicate_semicolon',
13+
'elseif',
14+
'empty_return',
15+
'encoding',
16+
'eof_ending',
17+
'extra_empty_lines',
18+
'function_call_space',
19+
'function_declaration',
20+
'include',
21+
'indentation',
22+
'join_function',
23+
'line_after_namespace',
24+
'linefeed',
25+
'list_commas',
26+
'logical_not_operators_with_successor_space',
27+
'lowercase_constants',
28+
'lowercase_keywords',
29+
'method_argument_space',
30+
'multiline_array_trailing_comma',
31+
'multiline_spaces_before_semicolon',
32+
'multiple_use',
33+
'namespace_no_leading_whitespace',
34+
'no_blank_lines_after_class_opening',
35+
'no_empty_lines_after_phpdocs',
36+
'object_operator',
37+
'operators_spaces',
38+
'parenthesis',
39+
'phpdoc_indent',
40+
'phpdoc_inline_tag',
41+
'phpdoc_no_access',
42+
'phpdoc_no_package',
43+
'phpdoc_scalar',
44+
'phpdoc_short_description',
45+
'phpdoc_to_comment',
46+
'phpdoc_trim',
47+
'phpdoc_type_to_var',
48+
'phpdoc_var_without_name',
49+
'remove_leading_slash_use',
50+
'remove_lines_between_uses',
51+
'return',
52+
'self_accessor',
53+
'short_array_syntax',
54+
'short_echo_tag',
55+
'short_tag',
56+
'single_array_no_trailing_comma',
57+
'single_blank_line_before_namespace',
58+
'single_line_after_imports',
59+
'single_quote',
60+
'spaces_before_semicolon',
61+
'spaces_cast',
62+
'standardize_not_equal',
63+
'ternary_spaces',
64+
'trailing_spaces',
65+
'trim_array_spaces',
66+
'unalign_equals',
67+
'unary_operators_spaces',
68+
'unused_use',
69+
'visibility',
70+
'whitespacy_lines',
71+
];
72+
73+
return Config::create()
74+
->finder(DefaultFinder::create()->in(__DIR__))
75+
->fixers($fixers)
76+
->level(FixerInterface::NONE_LEVEL)
77+
->setUsingCache(true);

.project

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<projectDescription>
3-
<name>phpcas-devel</name>
3+
<name>phpCAS-devel</name>
44
<comment></comment>
55
<projects>
66
</projects>

.travis.yml

+29-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,32 @@
11
language: php
2+
23
php:
3-
- "5.4"
4-
- "5.5"
5-
- "5.6"
6-
script:
7-
- cd test
8-
- phpunit TestSuite.php
4+
- 5.4
5+
- 5.5
6+
- 5.6
7+
- 7.0
8+
- hhvm
9+
10+
env:
11+
global:
12+
- setup=basic
13+
14+
matrix:
15+
include:
16+
- php: 5.4
17+
env: setup=lowest
18+
- php: 5.4
19+
env: setup=stable
20+
921
sudo: false
22+
23+
before_install:
24+
- travis_retry composer self-update
25+
26+
install:
27+
- if [[ $setup = 'basic' ]]; then travis_retry composer install --no-interaction --prefer-dist; fi
28+
- if [[ $setup = 'stable' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-stable; fi
29+
- if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable; fi
30+
31+
script: vendor/bin/phpunit
32+

CAS.php

-30
This file was deleted.

composer.json

+10-4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@
1414
"ext-curl": "*"
1515
},
1616
"require-dev": {
17-
"phpunit/phpunit": "~3.7.10"
17+
"fabpot/php-cs-fixer": "~1.11",
18+
"phpunit/phpunit": "~3.7"
1819
},
1920
"autoload": {
20-
"classmap": [
21-
"source/"
22-
]
21+
"psr-4": {
22+
"phpCAS\\": "source/"
23+
}
24+
},
25+
"autoload-dev": {
26+
"psr-4": {
27+
"phpCAS\\": "test/"
28+
}
2329
},
2430
"extra": {
2531
"branch-alias": {

docs/Upgrading

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
For security hardening purposes the verbose error messages to the web browsers
66
are now masked. If you want to have the verbose messages you need to use:
7-
phpCAS::setVerbose(true);
7+
CAS::setVerbose(true);
88
This will set the configuration to the old verbose mode that helps during
99
development and debugging.
1010

@@ -55,11 +55,11 @@ when validating the proxy tickets. The strings are compared starting from
5555
the beginning and must fully match with the proxies in the list.
5656

5757
Examples:
58-
phpCAS::allowProxyChain(new CAS_ProxyChain(array(
58+
CAS::allowProxyChain(new CAS_ProxyChain(array(
5959
'https://app.example.com/'
6060
)));
6161
or
62-
phpCAS::allowProxyChain(new CAS_ProxyChain(array(
62+
CAS::allowProxyChain(new CAS_ProxyChain(array(
6363
'/^https:\/\/app[0-9]\.example\.com\/rest\//',
6464
'http://client.example.com/'
6565
)));
@@ -68,7 +68,7 @@ For quick testing or in certain production screnarios you might want to
6868
allow allow any other valid service to proxy your service. To do so, add
6969
the "Any" chain:
7070

71-
phpcas::allowProxyChain(new CAS_ProxyChain_Any);
71+
CAS::allowProxyChain(new CAS_ProxyChain_Any);
7272

7373
THIS SETTING IS HOWEVER NOT RECOMMENDED FOR PRODUCTION AND HAS SECURITY
7474
IMPLICATIONS: YOU ARE ALLOWING ANY SERVICE TO ACT ON BEHALF OF A USER

docs/examples/config.example.php

+15-18
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@
44
* The purpose of this central config file is configuring all examples
55
* in one place with minimal work for your working environment
66
* Just configure all the items in this config according to your environment
7-
* and rename the file to config.php
7+
* and rename the file to config.php.
88
*
99
* PHP Version 5
1010
*
1111
* @file config.php
1212
* @category Authentication
13-
* @package PhpCAS
1413
* @author Joachim Fritschi <jfritschi@freenet.de>
1514
* @author Adam Franco <afranco@middlebury.edu>
1615
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
1716
* @link https://wiki.jasig.org/display/CASC/phpCAS
1817
*/
19-
20-
$phpcas_path = '../../source/';
18+
$CAS_path = '../../source/';
2119

2220
///////////////////////////////////////
2321
// Basic Config of the phpCAS client //
@@ -41,7 +39,7 @@
4139

4240
// The "real" hosts of clustered cas server that send SAML logout messages
4341
// Assumes the cas server is load balanced across multiple hosts
44-
$cas_real_hosts = array('cas-real-1.example.com', 'cas-real-2.example.com');
42+
$cas_real_hosts = ['cas-real-1.example.com', 'cas-real-2.example.com'];
4543

4644
// Client config for cookie hardening
4745
$client_domain = '127.0.0.1';
@@ -64,41 +62,40 @@
6462

6563
// Generating the URLS for the local cas example services for proxy testing
6664
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
67-
$curbase = 'https://' . $_SERVER['SERVER_NAME'];
65+
$curbase = 'https://'.$_SERVER['SERVER_NAME'];
6866
} else {
69-
$curbase = 'http://' . $_SERVER['SERVER_NAME'];
67+
$curbase = 'http://'.$_SERVER['SERVER_NAME'];
7068
}
7169
if ($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
72-
$curbase .= ':' . $_SERVER['SERVER_PORT'];
70+
$curbase .= ':'.$_SERVER['SERVER_PORT'];
7371
}
7472

75-
$curdir = dirname($_SERVER['REQUEST_URI']) . "/";
73+
$curdir = dirname($_SERVER['REQUEST_URI']).'/';
7674

7775
// CAS client nodes for rebroadcasting pgtIou/pgtId and logoutRequest
7876
$rebroadcast_node_1 = 'http://cas-client-1.example.com';
7977
$rebroadcast_node_2 = 'http://cas-client-2.example.com';
8078

8179
// access to a single service
82-
$serviceUrl = $curbase . $curdir . 'example_service.php';
80+
$serviceUrl = $curbase.$curdir.'example_service.php';
8381
// access to a second service
84-
$serviceUrl2 = $curbase . $curdir . 'example_service_that_proxies.php';
82+
$serviceUrl2 = $curbase.$curdir.'example_service_that_proxies.php';
8583

86-
$pgtBase = preg_quote(preg_replace('/^http:/', 'https:', $curbase . $curdir), '/');
87-
$pgtUrlRegexp = '/^' . $pgtBase . '.*$/';
84+
$pgtBase = preg_quote(preg_replace('/^http:/', 'https:', $curbase.$curdir), '/');
85+
$pgtUrlRegexp = '/^'.$pgtBase.'.*$/';
8886

89-
$cas_url = 'https://' . $cas_host;
87+
$cas_url = 'https://'.$cas_host;
9088
if ($cas_port != '443') {
91-
$cas_url = $cas_url . ':' . $cas_port;
89+
$cas_url = $cas_url.':'.$cas_port;
9290
}
93-
$cas_url = $cas_url . $cas_context;
91+
$cas_url = $cas_url.$cas_context;
9492

9593
// Set the session-name to be unique to the current script so that the client script
9694
// doesn't share its session with a proxied script.
9795
// This is just useful when running the example code, but not normally.
9896
session_name(
9997
'session_for:'
100-
. preg_replace('/[^a-z0-9-]/i', '_', basename($_SERVER['SCRIPT_NAME']))
98+
.preg_replace('/[^a-z0-9-]/i', '_', basename($_SERVER['SCRIPT_NAME']))
10199
);
102100
// Set an UTF-8 encoding header for internation characters (User attributes)
103101
header('Content-Type: text/html; charset=utf-8');
104-
?>

docs/examples/create_pgt_storage_db_table.php

+12-9
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,34 @@
88
* CAS_PGTStorage_Db() options:
99
* $db, $db_user, $db_password, $db_table, $driver_options
1010
* have to filled out directly. Option examples can be found in the
11-
* config.example.php
11+
* config.example.php.
1212
*
1313
* PHP Version 5
1414
*
1515
* @file create_pgt_storage_table.php
1616
* @category Authentication
17-
* @package PhpCAS
1817
* @author Joachim Fritschi <jfritschi@freenet.de>
1918
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
2019
* @link https://wiki.jasig.org/display/CASC/phpCAS
2120
*/
2221

22+
// Load the autoloader
23+
require_once '../../vendor/autoload.php';
24+
2325
// Load the settings from the central config file
2426
require_once 'config.php';
25-
// Load the CAS lib
26-
require_once $phpcas_path . '/CAS.php';
2727

28+
use phpCAS\CAS;
29+
use phpCAS\CAS\Client;
30+
use phpCAS\CAS\PGTStorage\Db;
2831

2932
// Dummy client because we need a 'client' object
30-
$client = new CAS_Client(
31-
CAS_VERSION_2_0, true, $cas_host, $cas_port, $cas_context, false
33+
$client = new Client(
34+
CAS::CAS_VERSION_2_0, true, $cas_host, $cas_port, $cas_context, false
3235
);
3336

34-
// Set the torage object
35-
$cas_obj = new CAS_PGTStorage_Db(
37+
// Set the storage object
38+
$cas_obj = new Db(
3639
$client, $db, $db_user, $db_password, $db_table, $driver_options
3740
);
3841
$cas_obj->init();
@@ -46,7 +49,7 @@
4649
<body>
4750
<div class="success">
4851
<?php
49-
echo 'Table <b>' . $db_table . '</b> successfully created in database <b>' . $db . '</b>';
52+
echo 'Table <b>'.$db_table.'</b> successfully created in database <b>'.$db.'</b>';
5053
?>
5154
</div>
5255
</body>

0 commit comments

Comments
 (0)