Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP4 constructors, preg_replace, method naming for subclasses #31

Merged
merged 6 commits into from Aug 25, 2018
Merged

PHP4 constructors, preg_replace, method naming for subclasses #31

merged 6 commits into from Aug 25, 2018

Conversation

fwolfsjaeger
Copy link
Contributor

I've fixed issue #28 with the second commit. The first one fixes another preg_replace delimiter issue, it's also allowed to use single-/double-quotes as delimiters. Also the method naming check didn't work for subclasses (eg. class SubClass extends ParentClass) as there were more tokens than just 5 to get after the first opening brace.

@fwolfsjaeger
Copy link
Contributor Author

It's just a partial fix for #28 though as it doesn't check for the namespace. Simply checking if there's a namespace defined in the same file would be simple, but it could then skip issues for the following (crappy yet allowed) syntax:

namespace name\space\to1 {
	class FirstClass {
		public function FirstClass() {
			print 'first class';
		}
	}

	$firstClass = new FirstClass();
}

namespace name\space\to2 {
	class SecondClass {
		public function SecondClass() {
			print 'second class';
		}
	}

	$secondClass = new SecondClass();
}

@fwolfsjaeger
Copy link
Contributor Author

Alright, namespace check for PHP4 style constructs is done as well ...

@wapmorgan
Copy link
Owner

Hello. Have you tested it?

@wapmorgan wapmorgan self-assigned this Aug 22, 2018
@fwolfsjaeger
Copy link
Contributor Author

fwolfsjaeger commented Aug 22, 2018 via email

@wapmorgan
Copy link
Owner

wapmorgan commented Aug 25, 2018

Is there any reason why you had the array_splice() for the method checks
strip from $class_start until $i - $class_start instead of 0 to $i?

That's to remove only tokens within class { ... } and to preserve use's and similar.

@wapmorgan wapmorgan merged commit b56163a into wapmorgan:master Aug 25, 2018
@wapmorgan
Copy link
Owner

Thanks for pr!

@fwolfsjaeger
Copy link
Contributor Author

fwolfsjaeger commented Aug 27, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants